package com.ss.tmall.service.impl;

import com.ss.tmall.mapper.ProductImageMapper;
import com.ss.tmall.pojo.ProductImage;
import com.ss.tmall.pojo.ProductImageExample;
import com.ss.tmall.service.ProductImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: ShengShuai
 * @Description:
 * @Date: Created in 下午 22:06  2017/12/26 0026
 * @Modified By:
 */
@Service
    public class ProductImageServiceImpl implements ProductImageService {
    @Autowired
    ProductImageMapper productImageMapper;
    @Override
    public  void  add(ProductImage productImage){
        productImageMapper.insert(productImage);
    }
    @Override
    public  void  delete(int id){
        productImageMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void  update(ProductImage productImage){
productImageMapper.updateByPrimaryKeySelective(productImage);
    }
    @Override
    public  ProductImage get(int id){
        return  productImageMapper.selectByPrimaryKey(id);
    }
    @Override
    public List list(int pid,String type ){
        ProductImageExample example =new ProductImageExample();
        example.createCriteria().andTypeEqualTo(type);
        return  productImageMapper.selectByExample(example);
    }
}
